function longestCommonPrefix(strs) {
  if (!strs || strs.length === 0) {
    return "";
  }
  const shortestStr = strs.reduce((shortest, current) => {
    if (current.length < shortest.length) {
      return current;
    }
    return shortest;
  }, strs[0]);
  console.log("shortestStr", shortestStr);
  let i = 0;
  while (
    i < shortestStr.length &&
    strs.every((str) => str[i] === shortestStr[i])
  ) {
    i++;
  }
  return shortestStr.substring(0, i);
}
const strings = ["flower", "flow", "flight"];
console.log(longestCommonPrefix(strings));

function eventloop() {
  setTimeout(() => {
    eventloop();
  }, 0);
}
